package com.mofang.activity.user;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.zxing.WriterException;
import com.mofang.R;
import com.mofang.activity.BaseTitleViewActiviey;
import com.zxing.encoding.EncodingHandler;

public class MyMaxCardActivity extends BaseTitleViewActiviey {

	private TextView txt_user_center_user_name;
	private TextView txt_user_center_user_phone;
	private ImageView iv_user_center_user_face;
	private ImageView iv_user_center_user_maxcode;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.activity_my_max_card);
		super.onCreate(savedInstanceState);
		setNavigationTitle("二维码名片");
		setNavigationLeftBtnImage(R.drawable.return_arrow);

		String contentString = "test";
		if (!contentString.equals("")) {
			// 根据字符串生成二维码图片并显示在界面上，第二个参数为图片的大小（350*350）
			Bitmap qrCodeBitmap = null;
			try {
				qrCodeBitmap = EncodingHandler.createQRCode(contentString, 350);
			} catch (WriterException e) {
				e.printStackTrace();
			}
			iv_user_center_user_maxcode.setImageBitmap(qrCodeBitmap);
		} else {
			Toast.makeText(MyMaxCardActivity.this, "Text can not be empty",
					Toast.LENGTH_SHORT).show();
		}
	}

	@Override
	protected void initView() {
		super.initView();
		txt_user_center_user_name = (TextView) findViewById(R.id.txt_user_center_user_name);
		txt_user_center_user_phone = (TextView) findViewById(R.id.txt_user_center_user_phone);
		iv_user_center_user_face = (ImageView) findViewById(R.id.iv_user_center_user_face);
		iv_user_center_user_maxcode = (ImageView) findViewById(R.id.iv_user_center_user_maxcode);
	}

}
